home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / assert / assert.h < prev    next >
C/C++ Source or Header  |  1994-02-11  |  2KB  |  71 lines

  1. /* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. /*
  20.  *    ANSI Standard: 4.2 DIAGNOSTICS    <assert.h>
  21.  */
  22.  
  23. #ifdef    _ASSERT_H
  24.  
  25. #undef    _ASSERT_H
  26. #undef    assert
  27.  
  28. #endif /* assert.h    */
  29.  
  30. #define    _ASSERT_H    1
  31. #include <features.h>
  32.  
  33. /* void assert(int expression);
  34.    If NDEBUG is defined, do nothing.
  35.    If not, and EXPRESSION is zero, print an error message and abort.  */
  36.  
  37. #ifdef    NDEBUG
  38.  
  39. #define    assert(expr)    ((void) 0)
  40.  
  41. #else /* Not NDEBUG.  */
  42.  
  43. #include <sys/cdefs.h>
  44.  
  45. __BEGIN_DECLS
  46.  
  47. /* This prints an "Assertion failed" message and aborts.  */
  48. extern __NORETURN int __assert_fail __P ((__const char *__assertion,
  49.                       __const char *__file,
  50.                       unsigned int __line,
  51.                       __const char *__function));
  52.  
  53. __END_DECLS
  54.  
  55. #define    assert(expr)                                   \
  56.   ((void) ((expr) || __assert_fail (__STRING(expr),                  \
  57.                     __FILE__, __LINE__, __ASSERT_FUNCTION)))
  58.  
  59. /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__'
  60.    which contains the name of the function currently being defined.
  61.    This is broken in G++ before version 2.6.  */
  62. #if (!defined (__GNUC__) || __GNUC__ < 2 || \
  63.      __GNUC_MINOR__ < (defined (__cplusplus) ? 6 : 4))
  64. #define __ASSERT_FUNCTION    ((__const char *) 0)
  65. #else
  66. #define __ASSERT_FUNCTION    __PRETTY_FUNCTION__
  67. #endif
  68.  
  69. #endif /* NDEBUG.  */
  70.  
  71.